# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=hxd
pkgver=2.5.0.0
pkgrel=2
groups=('blackarch' 'blackarch-misc' 'blackarch-windows')
pkgdesc='Freeware Hex Editor and Disk Editor.'
arch=('x86_64')
url='https://mh-nexus.de/en/hxd/'
license=('custom:unknown')
depends=('wine' 'wine_gecko' 'wine-mono')
makedepends=('innoextract')
source=('https://mh-nexus.de/downloads/HxDSetup.zip')
sha512sums=('ea97d98877342d725adcbfa075d5d5770470cf4a1d79477d577d299b6298d62f9a7fec8903633f8adcda7d306bff848751f8c788b611cc2d1074624a9153bc49')

prepare() {
  innoextract ./HxDSetup.exe
}

package() {
  cd app

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/windows/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" changelog.txt \
    readme.txt
  install -Dm 644 license.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm -rf *.txt
  cp -a --no-preserve=ownership * \
    "$pkgdir/usr/share/windows/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/windows/$pkgname
exec wine HxD64.exe
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

